package com.leyou.common.holders;

import com.leyou.common.auth.dto.UserInfo;

/**
 * @author 虎哥
 */
public class UserHolder {
    private static final ThreadLocal<UserInfo> tl = new ThreadLocal<>();

    /**
     * 获取用户
     * @return
     */
    public static UserInfo getUser() {
        return tl.get();
    }
    /**
     * 存储用户
     * @return 用户
     */
    public static void setUser(UserInfo user) {
        tl.set(user);
    }

    /**
     * 清理用户
     */
    public static void remove(){
        tl.remove();
    }
}
